﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace SynoManager.GUI
{
    public class VistaProgressBar : ProgressBar
    {
        const int WM_USER = 0x400;
        const int PBM_SETSTATE = WM_USER + 16;
        const int PBST_NORMAL = 0x0001;
        const int PBST_ERROR = 0x0002;
        const int PBST_PAUSED = 0x0003;

        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
        static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

        private ProgressBarState state = ProgressBarState.Normal;

        public ProgressBarState State
        {
            set
            {
                SendMessage(this.Handle, PBM_SETSTATE, (IntPtr)value, IntPtr.Zero);
                state = value;
            }
            get
            {
                return state;
            }
        }
    }

    public enum ProgressBarState
    {
        Normal = 0x0001,
        Error = 0x0002,
        Paused = 0x0003
    }
}
